package com.efesco.crm.pipeLine;

import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.SqlDataset;
import com.bstek.dorado.common.*;
import com.efesco.common.CommUtil;
import com.efesco.service.archives.SQLClass;

/**
 * pipeline_dataset_pipelineListener
 */
public class pipeline_dataset_pipelineListener extends AbstractDatasetListener {
  public boolean beforeLoadData(Dataset dataset)
     throws Exception {
	  SqlDataset ds = (SqlDataset) dataset;
		String sql = "select ps.*,p.SINGLE_COMPANY_ID,p.fe_dept_id,p.fe_employee_id,p.client_name,p.status,p.FIRST_CONTACT_TIME from s_pipeline p,s_pipeline_sub ps,s_single_company sc,[table] where p.pipelineid=ps.pipelineid and p.single_company_id=sc.single_company_id and ps.is_new=1 and (p.status is null or p.status=1) and [field] ";
		sql=CommUtil.getRoleSql(sql, "sc");
		sql += CommUtil.setConditionSQL(ds);
		String PROBABILITY=(String)ds.parameters().getValue("PROBABILITY");
/*		if(PROBABILITY!=null){
			if(PROBABILITY.equals("1"))
			sql+=" and ps.PROBABILITY=100 ";
			else if(PROBABILITY.equals("0")){
				sql+=" and ps.PROBABILITY<100 ";	
			}	
		}*/
		//System.out.println("sql==="+sql);
		ds.setSql(sql+" order by ps.input_date desc");
	    
    return true;
  }

}
